package com.nuc.kl.module.example.action;

import java.util.List;

import net.sf.json.JSONArray;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.nuc.kl.base.BaseAction;
import com.nuc.kl.module.example.entity.Example;
import com.opensymphony.xwork2.ActionContext;

@Controller
@Scope("prototype")
public class ExampleAction extends BaseAction<Example>{
	
	private List<Example> list;
	
	/**  测试 */
	public String test() throws Exception {
		return "test";
	}

	/** 列表 */
	public String listJson() throws Exception {
		list = exampleService.findAll();
		response.setContentType("text/html;charset=utf-8");
		String str = JSONArray.fromObject(list).toString();
		response.getWriter().write(str);
		return null;
	}
	
	/** 列表 */
	public String list() throws Exception {
		return "list";
	}

	/** 删除 */
	public String delete() throws Exception {
		return "toList";
	}

	/** 添加页面 */
	public String addUI() throws Exception {
		list = exampleService.findAll();
		ActionContext.getContext().put("list", list);
		
		
		return "saveUI";
	}

	/** 添加 */
	public String add() throws Exception {
		
		return "toList";
	}

	/** 修改页面 */
	public String editUI() throws Exception {
		
		
		return "saveUI";
	}

	/** 修改 */
	public String edit() throws Exception {
		return "toList";
	}

	
	

//	-----------------getter-----------setter---------------------------
	
	public List<Example> getList() {
		return list;
	}

	public void setList(List<Example> list) {
		this.list = list;
	}
	
	
	
}
